package sysu.el.graph.datagraph;

import java.util.ArrayList;

import sysu.el.array.idx.ArrIdx;
import sysu.el.array.idx.ArrIdxMan;

public class DataMan<T> extends Data<T>{

	public DataMan(){
		
	}
	
	public DataMan(ArrIdx idx, T t){
		super(idx, t);
		children = new ArrayList<DataMan>();
	}

	/* ******************************************************************** */
	/* *************************** Wrappers ******************************* */
	/* ******************************************************************** */
	public static<T> DataMan<T> wrap(ArrIdx idx, T t){
		DataMan<T> dgm = new DataMan<T>(idx, t);
		dgm.children = new ArrayList<DataMan>();
		return dgm;
	}
	
	
	public void addNode(DataMan node){
		this.children.add(node);
	}

	public boolean hasChild(){
		return children != null;
	}

	/**
	 * The success of the dismiss data relies on the children == null ?
	 * @return
	 */
	public boolean dismissData(){
		if (hasChild()){
			this.data = null;
			return true;
		}else	
			return false;
	}

	/**
	 * Suppressed Warning: Useless Comment.
	 * OK, I have considered make the children not generic, 
	 * make it ArrayList/<DataGraphMan/> instead.
	 * However, it is useless because when the level is lower, 
	 * the space needed is less. There is no big optimization by changing the w.
	 */
	public ArrayList<DataMan > children = null;

}
